/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jkoa.stripes.action;

import able.stripes.JSP;
import com.google.inject.Inject;
import com.jkoa.BaseActionBean;
import com.jkoa.model.Majikan;
import com.jkoa.service.MajikanService;
import com.jkoa.stripes.config.AuthRequired;
import java.util.Date;
import javax.swing.JOptionPane;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
import org.apache.log4j.Logger;

/**
 *
 * @author mr5rule
 */
@UrlBinding("/mkemasukan")
@AuthRequired
public class KemasukanMajikanActionBean extends BaseActionBean {

    private Majikan majikan;
      private final static Logger LOG = Logger.getLogger(KemasukanMajikanActionBean.class);


    @Inject MajikanService majikanService;

    @DefaultHandler
    public Resolution showForm() {
//        JOptionPane.showConfirmDialog(null, "testsetset");
        
        return new JSP("kemasukan_majikan.jsp");
        
    }

    public Resolution simpanMajikan(){
         if (majikan != null) {
              LOG.info("Kod Negeri" +majikan.getAlamatNegeri().getKod());
            majikan.setDimasuk("new user");
            majikan.setTrhMasuk(new Date());
            majikanService.saveMajikan(majikan);
         addSimpleMessage("Maklumat telah berjaya disimpan");
        }

        

      return new JSP("kemasukan_majikan.jsp");
    }

    public Majikan getMajikan() {
        return majikan;
    }

    public void setMajikan(Majikan majikan) {
        this.majikan = majikan;
    }

    public MajikanService getMajikanService() {
        return majikanService;
    }

    public void setMajikanService(MajikanService majikanService) {
        this.majikanService = majikanService;
    }
    
}
